module dogre.logmanager;

import dogre.log;
import dogre.internals.event;
import std.string;

extern(C)
{
    void* getLogManager();
    void* call_createLog(void* ptr, const(char)* name, bool defaultLog, bool debuggerOutput, bool suppressFileOutput);
    void call_setLogDetail(void* ptr, LoggingLevel ll);
    void* call_getDefaultLog(void* ptr);
    void* call_LogManager_getSingleton();
}

class LogManager
{
    static void* p;
    
    this(void* ptr)
    {
        assert(ptr);
        p = ptr;
    }
    
    this()
    {
        if(p is null)
            p = getLogManager();
        assert(p);
    }
    ~this(){}


    Log createLog(string name, bool defaultLog = false, bool debuggerOutput = true, bool suppressFileOutput = false)
    {
        return new Log(call_createLog(p, toStringz(name), defaultLog, debuggerOutput, suppressFileOutput));
    }

    void setLogDetail(LoggingLevel ll)
    {
        call_setLogDetail(p, ll);
    }

    static LogManager getSingleton()
    {
        if(p is null)
            p = call_LogManager_getSingleton();
        assert(p);
        return new LogManager(p);
    }
    
    Log getDefaultLog()
    {
        return new Log(call_getDefaultLog(p));
    }
}
